from fastapi import FastAPI
import uvicorn
from fastapi.middleware.cors import CORSMiddleware
import Character 
import KnowledgeBase
import consultantAssistant
app = FastAPI()

# 2、声明一个源列表；重点：要包含跨域的客户端 源
origins = [
    "*",
]

# 3、配置 CORSMiddleware
app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,  # 允许访问的源
    allow_credentials=True,  # 支持 cookie
    allow_methods=["*"],  # 允许使用的请求方法
    allow_headers=["*"]  # 允许携带的 Headers
)

app.include_router(Character.app, prefix="/Character", tags=["Character"])
app.include_router(KnowledgeBase.app, prefix="/KnowledgeBase", tags=["KnowledgeBase"])
app.include_router(consultantAssistant.app, prefix="/consultantAssistant", tags=["consultantAssistant"])

if __name__ == "__main__":
    uvicorn.run(app='server:app', host="0.0.0.0", port=8001, reload=False)
